package com.xysoft.admin.web;

import java.io.IOException;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import com.xysoft.admin.service.IManageRoleService;

@Controller
@RequestMapping(value = "/admin/managerole.jspx")
public class ManageRoleController extends BaseController {
	private IManageRoleService manageRoleService;
	
	@RequestMapping(params = "index")
	public String get(HttpServletResponse response, HttpServletRequest request, 
			HttpSession session) throws IOException {
		String res = this.manageRoleService.get(request, session);
		response.getWriter().print(res);
		return null;
	}
	
	@RequestMapping(params = "indexOForgan")
	public String getOrgan(HttpServletResponse response, HttpServletRequest request, 
			HttpSession session) throws IOException {
		String res = this.manageRoleService.getOrgan(request, session);
		response.getWriter().print(res);
		return null;
	}
	
	@RequestMapping(params = "indexOFaction")
	public String getAction(HttpServletResponse response, HttpServletRequest request, 
			HttpSession session) throws IOException {
		String res = this.manageRoleService.getAction(request, session);
		response.getWriter().print(res);
		return null;
	}
	
	@RequestMapping(params = "indexOFauto")
	@ResponseBody
	public Map<String,? extends Object> getAuto(HttpServletResponse response, HttpServletRequest request, 
			HttpSession session) throws IOException {
		return this.manageRoleService.getAuto(request, session);
	}
	
	@RequestMapping(params = "add")
	@ResponseBody
	public Map<String,? extends Object> add(HttpServletResponse response, HttpServletRequest request, 
			HttpSession session) throws IOException {
		return this.manageRoleService.addOrModify(request, session);
	}
	
	@RequestMapping(params = "edit")
	@ResponseBody
	public Map<String,? extends Object> modify(HttpServletResponse response, HttpServletRequest request, 
			HttpSession session) throws IOException {
		return this.manageRoleService.addOrModify(request, session);
	}
	
	@RequestMapping(params = "remove")
	@ResponseBody
	public Map<String,? extends Object> remove(HttpServletResponse response, HttpServletRequest request, 
			HttpSession session) throws IOException {
		return this.manageRoleService.remove(request, session);
	}
	
	@RequestMapping(params = "save")
	@ResponseBody
	public Map<String,? extends Object> save(HttpServletResponse response, HttpServletRequest request, 
			HttpSession session) throws IOException {
		return this.manageRoleService.save(request, session);
	}

	@Autowired
	public void setManageRoleService(IManageRoleService manageRoleService) {
		this.manageRoleService = manageRoleService;
	}
}
